home *** CD-ROM | disk | FTP | other *** search
/ CD Action 72 - Disc 2 / cdaction-72-2.iso / #bonus / Action Mag_23.exe / DATA / engine.js < prev    next >
Text File  |  2001-09-07  |  5KB  |  129 lines

  1. //sprawdza czy zosta│o podane has│o do wyszukania
  2. function check(ok)
  3. {
  4. if (ok == 'nie')
  5. {
  6. if (document.find.what.value != "")
  7.     {
  8.     znajdz();
  9.     } else {
  10.     error('Nie podano wyszukiwanego has│a.');
  11.     }
  12. }
  13. }
  14.  
  15. //G│≤wna funkcja engine'u AMSE
  16. wynik = new Array();
  17.  
  18. function znajdz()//bylo (tryb)
  19. {
  20. y=1;
  21. haslo_orginal = document.find.what.value;
  22. haslo = haslo_orginal.toLowerCase();
  23. //rozdzielaenia na autora i 
  24. for (x = 1; x <= (dane.length-1); x ++)
  25.     {
  26.     if ((document.find.opc_1.checked == true)&&(document.find.opc_2.checked == false))
  27.        {
  28.        //wyszukiwanie wg autorow artow
  29.        if (dane[x].autor.toLowerCase().indexOf(haslo) != -1)
  30.              {
  31.           wynik[y] = x;
  32.           y++;
  33.           }       
  34.        }
  35.     if ((document.find.opc_1.checked == false)&&(document.find.opc_2.checked == true))
  36.        {
  37.        //wyszukiwanie wg tytulow artow
  38.        if (dane[x].tytul.toLowerCase().indexOf(haslo) != -1)
  39.              {
  40.           wynik[y] = x;
  41.           y++;
  42.           }
  43.        }
  44.     if ((document.find.opc_1.checked == true)&&(document.find.opc_2.checked == true))
  45.        {
  46.        //wyszukiwanie wg tytulow artow i autorow
  47.        text = dane[x].autor;
  48.        text = text.toLowerCase(); 
  49.        text2 = dane[x].tytul;
  50.        text2 = text2.toLowerCase();
  51.        if ((text.indexOf(haslo) != -1) || (text2.indexOf(haslo) != -1))
  52.              {
  53.           wynik[y] = x;
  54.           y++;
  55.           }
  56.        }
  57.     }
  58. draw_results(wynik);
  59. }
  60.  
  61.  
  62. //wyswietla strone zawierajaca wyniki wyszukiwania
  63. bgcol = new Array();
  64. bgcol[1] = "#b2c5ec";
  65. bgcol[3] = "#8ba8e2";
  66. swcol = 1;
  67.  
  68. function draw_results(tablica)
  69. {
  70. document.clear();
  71. //poczatek
  72. header = '<html><head><title>Action Mag [' + numer_action_maga + '] - wyniki wyszukiwania</title><link rel=stylesheet href="style.css" type="text/css"></head>';
  73. header +='<BODY><a name="gora"><TABLE width=780 border=0 cellpadding=0 cellspacing=0 align=center cols=4><tr><td width=25><td width=184><td width=543><td width=28></tr><tr><td colspan=4 width=780><img src="images/constr/1_top.gif" width="780" height="65" alt="" border="0" usemap="#cda"></td></tr><tr><td colspan=4 width=780><img src="images/constr/2_m_top.gif" width="780" height="37" alt="" border="0" usemap="#menu_top"></td></tr><tr><td width=25 background="images/constr/amag_lft.gif"> </td><td width=184 background="images/constr/3_.gif">';
  74. header +='<td width=543><table border=0 cellspacing=0 cellpadding=1 align=center><tr><td class=title1><table border=0 cellspacing=0 cellpadding=0 align=center><tr><td class=title2> ..:: Wyniki wyszukiwania ::.. </td></table></table>';
  75. header +='<hr noshade color="#658bd9"><br>';
  76. header +='<table width=543 border=0 cellpadding=3 align=center>';
  77. document.write(header);
  78.  
  79. for (x = 1; x <= (tablica.length-1); x++)
  80.     {
  81.     swcol = swcol * -1;
  82.     bgc = bgcol[2+swcol];
  83.     document.write('<tr><td style="background-color: ' + bgc + '"><a id=search href="' + dane[tablica[x]].sciezka + '"> ' + dane[tablica[x]].tytul + '</a></td><td style="background-color: ' + bgc + '"><b>' + dane[tablica[x]].autor + '</b></td></tr>');
  84.     }
  85. if (tablica.length == 0)
  86.    {
  87.    document.write('Nie znaleziono ┐adnych artyku│≤w odpowiadaj╣cych kryteriom wyszukiwania.');
  88.    }
  89.  
  90. //zakonczenie
  91. ending = '</table>';
  92. document.write(ending);
  93.  
  94. document.write('<br><br><a href="javascript:history.back();"><< Powr≤t do poprzedniej strony</a>');
  95.  
  96. ending ='</td><td background="images/constr/4_.gif"> </td></tr><tr><td colspan=4 width=780><img src="images/constr/7_design.gif" width="780" height="45" alt="" border="0" usemap="#design"></td></tr></TABLE><map name=cda><area shape=rect coords="681, 24, 780, 64" href="www.cdaction.com.pl"></map><map name=menu_top><area shape=rect coords="79, 2, 151, 16" href="index.htm"><area shape=rect coords="364, 2, 425, 16" onclick="history.go(-1);"><area shape=rect coords="544, 2, 605, 16" onclick="history.go(1);"></map><map name=design><area shape=rect coords="45, 25, 209, 38" href="mailto:mike_b@poczta.fm"><area shape=rect coords="668, 24, 741, 38" href="#gora"></map></BODY></html>';
  97. document.write(ending);
  98. }
  99.  
  100. function error(opis)
  101. {
  102. alert('-- Action Mag Searching Engine --\n               by Glorfindel\n\n            BúÑD\n\n' + opis);
  103. }
  104.  
  105. function random_art(ok)
  106. {
  107. if (ok == 'nie')
  108. {
  109. x = parseInt(Math.random()*(dane.length-1)+1);
  110. alert('"' + dane[x].tytul + '"' + '\n\      by\n' + dane[x].autor);
  111. location.href=dane[x].sciezka;
  112. }
  113. }
  114.  
  115. //koniec wyszukiwarki
  116.  
  117.  
  118. //ROLLOVER
  119. function img_on(obraz)
  120. {
  121. document.images[obraz].src="images/constr/" + obraz+"_on.gif";
  122. }
  123.  
  124. function img_off(obraz)
  125. {
  126. document.images[obraz].src="images/constr/" + obraz+"_off.gif";
  127. }
  128.  
  129.